package pl.edu.agh.logview.model;

import java.util.Date;

public abstract class AbstractVertex implements Vertex {
	public int getX() {
		return x;
	}
	public void setX(int x) {
		this.x = x;
	}
	public int getY() {
		return y;
	}
	public void setY(int y) {
		this.y = y;
	}
	public Object getVertexObject() {
		return vertexObject;
	}
	public void setVertexObject(Object vertexObject) {
		this.vertexObject = vertexObject;
	}
	public VertexType getVertexType() {
		return vertexType;
	}
	public void setVertexType(VertexType vertexType) {
		this.vertexType = vertexType;
	}
	private int x;
	private int y;
	
	private Object vertexObject;
	protected VertexType vertexType;
	
	private Date date;
	
	public Date getDate() {
		return date;
	}
	
	public void setDate(Date d) {
		date = d;
	}
	
	public int getCenterX() {
		return (int) (x+ (vertexType.getWidth() / 2) );
	}
	
	@Override
	public int compareTo(Vertex o) {
		if (getVertexType() == VertexType.VERTEX_AGENT) {
			if (o.getVertexType() == VertexType.VERTEX_AGENT)
				return 0;
			else 
				return -1;
		}
		if (getVertexType() == VertexType.VERTEX_ENDING) {
			if (o.getVertexType() == VertexType.VERTEX_ENDING) {
				return 0;
			}
			else {
				return 1;
			}
		}
		if (getDate() != null && o.getDate() != null) {
			if (getDate().getTime() < o.getDate().getTime() ) 
				return -1;
			else 
				return 1;
		}
		return 0;
	}
}
